import React from 'react';
import { Modal, notification } from 'antd';
import ajax from '../../utils/ajax';
import { Input } from 'antd';

//图片的查看详情组件

class DesView extends React.Component {

  state = {
    des : '',  //显示的图片列表
    newDes : '',
    dn : '',
    desViewVisible: false
  }

  desView = () => {
    var _this = this;
    let dn = _this.props.dn;
    _this.setState({ dn: dn });
    ajax.post({
          url: "/accountbill/getDes",
          params: {dn:dn},
          success: function (res) {
            _this.setState({ des : res.data });
            _this.setState({ desViewVisible : true });
          }
    })
    
  }

  hideModal = () => {
    this.setState({ desViewVisible: false });
  }

  handleModalOk = () => {
    var _this = this;
    let dn = _this.state.dn;
    let newDes = _this.state.newDes;
    ajax.post({
          url: "/accountbill/modifyDes",
          params: {dn : dn, newDes : newDes},
          success: function (res) {
            window.location.reload();
          }
    })
    this.setState({ desViewVisible: false });
  }

  getInputValue= (e) =>{
    var _this = this;
    _this.setState({newDes : e.target.value});
  }

  render() {
    return (
      <div>
        <a href="javascript:void(0)" onClick={this.desView}>修改备注</a>
        <Modal title="修改备注" visible={this.state.desViewVisible} onOk={this.handleModalOk}
          onCancel={this.hideModal}>
          
         <input type="textarea"
            style={{ width: '100%', height: 100 }}
            placeholder="请输入备注"
            defaultValue = {this.state.des}
            onChange =  {this.getInputValue}
          />
        </Modal>
      </div>
    );
  }
}

export default DesView;
